package pck_Service03;

import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.view.Display;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import com.nPones.MainActivity;
import mainSrc.GlobalSaveData;

public class service_TopView
  extends Service
{
  private int Point_dx;
  private int Point_dy;
  private int Point_mx;
  private int Point_my;
  private int Point_sx;
  private int Point_sy;
  private float Point_tx;
  private float Point_ty;
  private float Ratio;
  public int Size;
  private long Timer;
  private long TimerG;
  private long TimerT;
  private int gravity_Fric;
  private int gravity_Inc;
  private int gravity_Max;
  final Handler handler = new Handler()
  {
    @SuppressLint({"HandlerLeak"})
    public void handleMessage(Message paramAnonymousMessage)
    {
      try
      {
        service_TopView.this.m_WindowManager.updateViewLayout(service_TopView.this.m_AOTView, service_TopView.this.m_Params);
        return;
      }
      catch (IllegalArgumentException paramAnonymousMessage) {}
    }
  };
  public int isThisMove;
  private service_GLGameView m_AOTView;
  public WindowManager.LayoutParams m_Params;
  private ServiceThread m_ServiceThread;
  private View.OnTouchListener m_TouchListener = new View.OnTouchListener()
  {
    public boolean onTouch(View paramAnonymousView, MotionEvent paramAnonymousMotionEvent)
    {
      int i;
      switch (paramAnonymousMotionEvent.getAction())
      {
      default: 
      case 0: 
      case 2: 
        for (;;)
        {
          return true;
          service_TopView.this.Point_tx = paramAnonymousMotionEvent.getX();
          service_TopView.this.Point_ty = paramAnonymousMotionEvent.getY();
          service_TopView.this.Point_sx = 0;
          service_TopView.this.Point_sy = 0;
          service_TopView.this.StopDelta();
          service_ServiceGlobal.StatePoint = 0;
          service_ServiceGlobal.m_Character.MovePose = 0;
          service_TopView.this.TimerT = service_TopView.this.Timer;
          continue;
          if (service_TopView.this.Timer - service_TopView.this.TimerT > 50L)
          {
            service_TopView.this.Point_sx = 0;
            service_TopView.this.Point_sy = 0;
            service_TopView.this.TimerT = service_TopView.this.Timer;
          }
          i = (int)(paramAnonymousMotionEvent.getX() - service_TopView.this.Point_tx);
          int j = (int)(paramAnonymousMotionEvent.getY() - service_TopView.this.Point_ty);
          paramAnonymousView = service_TopView.this;
          paramAnonymousView.Point_sx += i;
          paramAnonymousView = service_TopView.this;
          paramAnonymousView.Point_sy += j;
          paramAnonymousView = service_TopView.this.m_Params;
          paramAnonymousView.x += i;
          paramAnonymousView = service_TopView.this.m_Params;
          paramAnonymousView.y += j;
          service_TopView.this.CheckPointOut();
          service_TopView.this.m_WindowManager.updateViewLayout(service_TopView.this.m_AOTView, service_TopView.this.m_Params);
        }
      }
      if ((service_TopView.this.Point_sx * service_TopView.this.Point_sx + service_TopView.this.Point_sy * service_TopView.this.Point_sy > 7225) && (service_TopView.this.Timer - service_TopView.this.TimerT < 20L))
      {
        i = service_TopView.this.Point_sx;
        if (i < 23) {
          break label398;
        }
        service_TopView.this.Point_dx = 23;
      }
      for (;;)
      {
        service_TopView.this.Point_dy = (service_TopView.this.Point_sy / 10);
        service_ServiceGlobal.StatePoint = 5;
        break;
        label398:
        if (i <= -23) {
          service_TopView.this.Point_dx = -23;
        } else {
          service_TopView.this.Point_dx = i;
        }
      }
    }
  };
  private WindowManager m_WindowManager;
  
  public void CheckPointOut()
  {
    if (this.m_Params.x > this.Point_mx) {
      this.m_Params.x = this.Point_mx;
    }
    if (this.m_Params.y > this.Point_my) {
      this.m_Params.y = this.Point_my;
    }
    if (this.m_Params.x < 0) {
      this.m_Params.x = 0;
    }
    if (this.m_Params.y < 0) {
      this.m_Params.y = 0;
    }
  }
  
  int CheckPointWhere()
  {
    if (service_ServiceGlobal.StatePoint == 0) {
      return 0;
    }
    if (this.m_Params.y == 0)
    {
      if (this.m_Params.x == this.Point_mx) {
        return 9;
      }
      if (this.m_Params.x == 0) {
        return 7;
      }
      return 8;
    }
    if (this.m_Params.x == this.Point_mx)
    {
      if (this.m_Params.y == this.Point_my) {
        return 3;
      }
      return 6;
    }
    if (this.m_Params.x == 0)
    {
      if (this.m_Params.y == this.Point_my) {
        return 1;
      }
      return 4;
    }
    if (this.m_Params.y == this.Point_my) {
      return 2;
    }
    return 5;
  }
  
  public void Moving()
  {
    switch (this.isThisMove)
    {
    }
    for (;;)
    {
      this.isThisMove = 0;
      return;
      this.Point_dx = 20;
      this.Point_dy = -10;
      continue;
      this.Point_dx = -20;
      this.Point_dy = -10;
      continue;
      this.Point_dy = -2;
      continue;
      this.Point_dy = 2;
      continue;
      this.Point_dx = 2;
      continue;
      this.Point_dx = -2;
      continue;
      this.Point_dy = 1;
    }
  }
  
  public void SetMaxPoint()
  {
    this.Point_mx = (this.m_WindowManager.getDefaultDisplay().getWidth() - this.Size);
    this.Point_my = (this.m_WindowManager.getDefaultDisplay().getHeight() - this.Size);
  }
  
  public void StopDelta()
  {
    this.Point_dx = 0;
    this.Point_dy = 0;
  }
  
  public IBinder onBind(Intent paramIntent)
  {
    return null;
  }
  
  public void onConfigurationChanged(Configuration paramConfiguration)
  {
    SetMaxPoint();
    CheckPointOut();
  }
  
  public void onCreate()
  {
    PendingIntent localPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0);
    Notification localNotification = new Notification(2130837559, "Service Start", System.currentTimeMillis());
    localNotification.setLatestEventInfo(this, "nPone's Game", "Pet Designer Free", localPendingIntent);
    startForeground(2348, localNotification);
    this.m_AOTView = new service_GLGameView(this);
    this.m_AOTView.setOnTouchListener(this.m_TouchListener);
    this.m_WindowManager = ((WindowManager)getSystemService("window"));
    int i = this.m_WindowManager.getDefaultDisplay().getWidth();
    int j = this.m_WindowManager.getDefaultDisplay().getHeight();
    this.Ratio = (i / 480);
    if (this.Ratio < j / 800) {
      this.Ratio = (j / 800);
    }
    if (this.Ratio > 1.0F) {
      this.Ratio = 1.0F;
    }
    this.Size = GlobalSaveData.GetInstance().SetSize();
    this.Size = ((int)(this.Size * this.Ratio));
    this.gravity_Inc = GlobalSaveData.GetInstance().SetGravity(1);
    this.gravity_Max = GlobalSaveData.GetInstance().SetGravity(2);
    this.gravity_Fric = GlobalSaveData.GetInstance().SetGravity(3);
    this.m_Params = new WindowManager.LayoutParams(this.Size, this.Size, 2002, 8, -3);
    this.m_Params.gravity = 51;
    this.m_Params.x = (i / 2 - (int)(64.0F * this.Ratio));
    this.m_Params.y = 100;
    this.m_WindowManager.addView(this.m_AOTView, this.m_Params);
    this.Point_mx = 0;
    this.Point_my = 0;
    StopDelta();
    this.Point_sx = 0;
    this.Point_sy = 0;
    this.Point_tx = 0.0F;
    this.Point_tx = 0.0F;
    this.Timer = 0L;
    this.TimerT = 0L;
    this.TimerG = 0L;
    this.isThisMove = 0;
    SetMaxPoint();
    service_ServiceGlobal.initFunc1(1, this, this.Timer);
    this.m_ServiceThread = new ServiceThread();
    this.m_ServiceThread.start();
  }
  
  public void onDestroy()
  {
    int i = 1;
    this.m_ServiceThread.loop = false;
    for (;;)
    {
      if (i == 0)
      {
        if ((this.m_WindowManager != null) && (this.m_AOTView != null)) {
          this.m_WindowManager.removeView(this.m_AOTView);
        }
        super.onDestroy();
        return;
      }
      try
      {
        this.m_ServiceThread.join();
        i = 0;
      }
      catch (InterruptedException localInterruptedException) {}
    }
  }
  
  class ServiceThread
    extends Thread
  {
    public boolean loop = true;
    
    ServiceThread() {}
    
    public void run()
    {
      for (;;)
      {
        if (!this.loop) {
          return;
        }
        try
        {
          int i = service_ServiceGlobal.StatePoint;
          service_TopView.this.CheckPointOut();
          service_ServiceGlobal.StatePoint = service_TopView.this.CheckPointWhere();
          if (i != service_ServiceGlobal.StatePoint)
          {
            if ((i != 1) && (i != 3)) {
              service_ServiceGlobal.m_Character.MovePose = 0;
            }
            service_ServiceGlobal.m_Character.SetAnimationPlayInfoFree();
          }
          service_TopView.this.Moving();
          Object localObject1 = service_TopView.this.handler.obtainMessage();
          switch (service_ServiceGlobal.StatePoint)
          {
          }
          for (;;)
          {
            Object localObject2 = service_TopView.this.m_Params;
            ((WindowManager.LayoutParams)localObject2).x += service_TopView.this.Point_dx;
            localObject2 = service_TopView.this.m_Params;
            ((WindowManager.LayoutParams)localObject2).y += service_TopView.this.Point_dy;
            service_TopView.this.handler.sendMessage((Message)localObject1);
            for (;;)
            {
              service_TopView.this.CheckPointOut();
              sleep(10L);
              localObject1 = service_TopView.this;
              ((service_TopView)localObject1).Timer += 1L;
              localObject1 = service_TopView.this;
              ((service_TopView)localObject1).TimerG += 1L;
              service_ServiceGlobal.Timer = service_TopView.this.Timer;
              break;
              service_TopView.this.StopDelta();
            }
            if ((service_TopView.this.TimerG % 5L == 0L) && (service_TopView.this.Point_dy < service_TopView.this.gravity_Max))
            {
              localObject2 = service_TopView.this;
              ((service_TopView)localObject2).Point_dy += service_TopView.this.gravity_Inc;
            }
            if (service_TopView.this.TimerG % 5L == 0L)
            {
              if (service_TopView.this.Point_dx < service_TopView.this.gravity_Fric) {
                break label405;
              }
              localObject2 = service_TopView.this;
              ((service_TopView)localObject2).Point_dx -= service_TopView.this.gravity_Fric;
            }
            for (;;)
            {
              localObject2 = service_TopView.this.m_Params;
              ((WindowManager.LayoutParams)localObject2).x += service_TopView.this.Point_dx;
              localObject2 = service_TopView.this.m_Params;
              ((WindowManager.LayoutParams)localObject2).y += service_TopView.this.Point_dy;
              service_TopView.this.handler.sendMessage((Message)localObject1);
              break;
              label405:
              if (service_TopView.this.Point_dx <= service_TopView.this.gravity_Fric)
              {
                localObject2 = service_TopView.this;
                ((service_TopView)localObject2).Point_dx += service_TopView.this.gravity_Fric;
              }
              else
              {
                service_TopView.this.Point_dx = 0;
              }
            }
          }
        }
        catch (InterruptedException localInterruptedException) {}
      }
    }
  }
}


/* Location:           D:\Tool\AndroidKiller_v1.3.1\projects\petdesigner\ProjectSrc\classes-dex2jar.jar
 * Qualified Name:     pck_Service03.service_TopView
 * JD-Core Version:    0.7.0.1
 */